package com.niit.dao.impl;

import java.util.List;

import com.niit.bean.Classify;
import com.niit.dao.ClassifyDao;
import com.niit.utils.DbUtil;

public class ClassifyDaoImpl implements ClassifyDao {
	
	private DbUtil util = new DbUtil();
	
	@Override
	public int add(Classify t) {
		String sql = "insert into tb_classify (classify,descri) values (?)";
		int a = util.update(sql, t.getClassify());
		return a;
	}

	@Override
	public int delete(Classify t) {
		String sql = "delete from tb_classify where id=? ";
		int a = util.update(sql,t.getId());
		return a;
	}

	@Override
	public int update(Classify t) {
		String sql = "update tb_classify set classify=?";
		int a = util.update(sql, t.getClassify());
		return a;
	}

	@Override
	public List<Classify> findAll(int start, int end) {
		String sql = "select * from (select rownum r,tb_classify.* from tb_classify) a where a.r>? and a.r<=? ";
		List<Classify> list = util.select(sql, Classify.class, start,end);
		return list;
	}

	@Override
	public int findTotal() {
		String sql = "select count(*) from tb_classify";
		int count = util.selectCount(sql);
		return count;
	}

}
